package com.lemon.components.ant.beans;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import org.codehaus.plexus.util.StringUtils;

public class TemplateContext {

	private String serviceName;
	private String modelName;
	private String servicePackage;
	private String controllerPackage;
	private String controllerPrefix;
	private List<TableColumns> columns;
	private String serialVersionUID;
	private String primaryKey;
	private String primaryKeyMethod;
	private List<TableColumns> searchColumns;
	private EnumInfo enuminfo;
	private String jspath;
	private String jsprefix;
	
	public String getServiceName() {
		return serviceName;
	}
	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}
	public String getModelName() {
		return modelName;
	}
	public void setModelName(String modelName) {
		this.modelName = modelName;
	}
	public String getServicePackage() {
		return servicePackage;
	}
	public void setServicePackage(String servicePackage) {
		this.servicePackage = servicePackage;
	}
	@Override
	public String toString() {
		return "TemplateContext [serviceName=" + serviceName + ", modelName=" + modelName + ", servicePackage="
				+ servicePackage + ", controllerPackage=" + controllerPackage + ", controllerPrefix=" + controllerPrefix
				+ ", columns=" + columns + ", serialVersionUID=" + serialVersionUID + ", primaryKey=" + primaryKey
				+ ", primaryKeyMethod=" + primaryKeyMethod + ", searchColumns=" + searchColumns + ", enuminfo="
				+ enuminfo + ", jspath=" + jspath + ", jsprefix=" + jsprefix + "]";
	}
	public String getControllerPrefix() {
		return controllerPrefix;
	}
	public void setControllerPrefix(String controllerPrefix) {
		this.controllerPrefix = controllerPrefix;
	}
	public String getControllerPackage() {
		return controllerPackage;
	}
	public void setControllerPackage(String controllerPackage) {
		this.controllerPackage = controllerPackage;
	}
	public List<TableColumns> getColumns() {
		return columns;
	}
	public void setColumns(List<TableColumns> columns) {
		this.columns = columns;
	}
	public String getSerialVersionUID() {
		if(StringUtils.isBlank(serialVersionUID)){
			Math.floor(Math.random()*19);
			DecimalFormat format = new DecimalFormat("###################");
			return format.format(Math.random()*1000000000000000000L);
		} else {
			return serialVersionUID;
		}
	}
	public void setSerialVersionUID(String serialVersionUID) {
		this.serialVersionUID = serialVersionUID;
	}
	public String getPrimaryKeyMethod() {
		return primaryKeyMethod;
	}
	public void setPrimaryKeyMethod(String primaryKeyMethod) {
		this.primaryKeyMethod = primaryKeyMethod;
	}
	public List<TableColumns> getSearchColumns() {
		if(searchColumns!=null&&searchColumns.size()>0){
			return searchColumns;
		} else {
			if(searchColumns == null){
				searchColumns = new ArrayList<>();
			} else {
				searchColumns.clear();
			}
			columns.forEach(column -> {
				if(column.isSearch()||column.getSelect() != null){
					searchColumns.add(column);
				}
			});
			return searchColumns;
		}
	}
	public void setSearchColumns(List<TableColumns> searchColumns) {
		this.searchColumns = searchColumns;
	}
	public String getPrimaryKey() {
		return primaryKey;
	}
	public void setPrimaryKey(String primaryKey) {
		this.primaryKey = primaryKey;
	}
	public EnumInfo getEnuminfo() {
		return enuminfo;
	}
	public void setEnuminfo(EnumInfo enuminfo) {
		this.enuminfo = enuminfo;
	}
	public String getJspath() {
		return jspath;
	}
	public void setJspath(String jspath) {
		this.jspath = jspath;
	}
	public String getJsprefix() {
		return jsprefix;
	}
	public void setJsprefix(String jsprefix) {
		this.jsprefix = jsprefix;
	}
}
